import request from "@/apis/request";


//获取推荐文章
export const getRecommendArticle = () => {
    return request({
        url: '/recommend/recommendArticle',
        method: 'get'
    })
}
//获取全部文章
export const getAllArticle = () => {
    return request({
        url: '/article/getAllArticle',
        method: 'get'
    })
}
//获取文章详情
export const getArticelDetail = (articleId) => {
    return request({
        url: '/article/getArticleDetail',
        method: 'get',
        params: {
            articleId
        }
    })
}
//点赞
export const likes = (articleId) => {
    return request({
        url: '/likes/addLike',
        method: 'get',
        params: {
            articleId
        }
    })
}
//取消点赞
export const cancelLikes = (articleId) => {
    return request({
        url: '/likes/cancelLike',
        method: 'get',
        params: {
            articleId
        }
    })
}
//获取用户个人文章

export const getUserlArticle = () => {
    return request({
        url: '/article/getUserArticle',
        method: 'get',
    })
}
//获取收藏文章
export const getFavorite = () => {
    return request({
        url: '/favorite/getUserFavoriteList',
        method: 'get',
    })
}
//获取创建文章
export const createArticle = ({title, content, createDate}) => {
    return request({
        url: '/article/addArticle',
        method: 'post',
        data: {
            title, content, createDate
        }
    })
}
// 删除我的文章
export const deleteArticleById = (id) => {
    return request({
        url: '/article/deleteArticle',
        method: 'get',
        params: {
            id
        }
    })
}
//编辑我的文章
export const updateArticleById = ({id, title, content, createDate}) => {
    return request({
        url: '/article/updateArticle',
        method: 'post',
        data: {
            id, title, content, createDate
        }
    })
}
//收藏文章
export const addFavArticle = (articleId) => {
    return request({
        url: '/favorite/addFavoriteArticle',
        method: 'get',
        params: {
            articleId
        }
    })
}
//取消收藏文章
export const cancleFav = (id) => {
    return request({
        url: '/favorite/cancelFavoriteArticle',
        method: 'get',
        params: {
            id
        }
    })
}
//评论文章
export const addCommentForArticle = ({articleId, createDate, content,}) => {
    return request({
        url: '/comment/addComment',
        method: 'post',
        data: {
            articleId,
            createDate,
            content,
        }
    })
}
//回复评论
export const replaySonComment = ({parentCommentId,articleId, content,createDate}) => {
    return request({
        url: '/comment/replyComment',
        method: 'post',
        data: {
            parentCommentId,
            articleId,
            content,
            createDate,
        }
    })
}
//模糊查询
export const getArticleByKeyword  = (keyword) => {
    return request({
        url: '/article/getArticleByKeyword',
        method: 'get',
        params:{
            keyword
        }
    })
}
//删除评论
export const deleteComment  = (replyCommentId) => {
    return request({
        url: '/comment/deleteReplyComment',
        method: 'get',
        params:{
            replyCommentId
        }
    })
}